package myfile

import (
	"huohuo-compress/backend/model"
)

// GetCompressFileListWithSelect 选择文件
func GetCompressFileListWithSelect(fileList []string, compressFileList []model.CompressFile) []model.CompressFile {
	var existFilePathList []string
	for _, file := range compressFileList {
		existFilePathList = append(existFilePathList, file.FilePath)
	}
	for _, filePath := range fileList {
		var existFile = false
		for _, existPathPath := range existFilePathList {
			if filePath == existPathPath {
				existFile = true
				break
			}
		}
		if existFile {
			continue
		}
		var item model.CompressFile
		item.FilePath = filePath
		err := item.GetFileInfo()
		if err != nil {
			item.Status = "error"
		} else {
			item.Status = "wait"
		}
		compressFileList = append(compressFileList, item)
	}
	return compressFileList
}
